/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ca.ubc.icapture.genapha.test.tld;


import icapture.SQLMgr;

import icapture.beans.DB.GenotypingRun;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;



/**
 *
 * @author btripp
 */
public class GenotypingRunList extends TagSupport {
    private String property;
    private String multiple = "yes";
    private String  size = "8";

    public int doStartTag() throws JspException {
        try {
            JspWriter out = pageContext.getOut();
            HttpSession session = pageContext.getSession();
            ArrayList<GenotypingRun> list = SQLMgr.getGenotypingRuns();

            if(size.length()==0)
                out.println("<SELECT  ID=\"" + property +  "\" NAME=\"" + property +  "\" >");
            else
                out.println("<SELECT  ID=\"" + property +  "\" NAME=\"" + property +  "\" multiple=\""+ multiple +"\" size=\""+ size +"\">");
            for(GenotypingRun gr: list){
                out.println("<OPTION VALUE=\"" + gr.getGenotypingRunID() + "\" >" + gr.getDescription() + " - " + gr.getDate().toString());
            }
            out.println("</SELECT>");


        } catch (Exception e) {
            System.out.println("the ScreenIconTag error");
            e.printStackTrace();
        }

        return EVAL_BODY_INCLUDE;
    }

    /**
     * Method called at end of tag.
     *
     * @return EVAL_PAGE
     */
    public int doEndTag() {
        return EVAL_PAGE;
    }

    public String getProperty() {
        return property;
    }

    public void setProperty(String property) {
        this.property = property;
    }

    public String getMultiple() {
        return multiple;
    }

    public void setMultiple(String multiple) {
        this.multiple = multiple;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

}
